<?php

/**)
 *
 * This class allow you to get Wikipedia PageSource directly from Wikipedia over Http.
 * Using this method you donc need to download the dump.
 * This implementation downloads the english version of wikipedia articles.
 *
 * You can note that whe use simplexml library in order to parse the downloaded xml,
 * this method is used because the xml is tiny. In order to parse the complete dump (~ 4G)
 * we must do otherwise, see wikipediaFileSource for details.
 */

class wikipediaNetSource implements PageCollection {
	private $language;
	
	public function __construct ($language) {
		$this->language = $language;
	}
	
	public function getLanguage () {
		return $this->language;
	}
	
	public function getSource ($pageID) {
		$url = 'http://en.wikipedia.org/w/index.php?title=Special:Export&pages='.$pageID.'&limit=1&action=submit';
		$context = stream_context_create (
			array ("http" => array ("user_agent" => "DBpedia"))
		);
		$xml = simplexml_load_string (file_get_contents ($url, false, $context));
		return $xml->page->revision->text;
	}
	
	public function getRevision ($pageID) {
		return null;
	}
}
?>